const app = new Vue({
  el: '#app',

  data: {
    search: '',
    list: [],
  },

  computed: {
    filteredList() {
      if (this.search === '') {
        return this.list;
      }

      const re = new RegExp(this.search, 'i');
      return this.list.filter(it => re.test(it.name) || re.test(it.file) || re.test(it.appid));
    },
  },

  methods: {
    // 编译
    async build(it) {
      const data = await $.get('/api/build', { file: it.file });
      it.time = data.time;
    },

    // 发布
    async release(it) {
      const data = await $.get('/api/release', { file: it.file });
      console.log(data);
    },
  },

  created() {
    $.get('/api/files').then((data) => {
      this.list = data.list;
    });
  },
});
